# -*- coding:utf-8 -*-
class Solution:
    # array 二维列表
    def Find(self, target, array):
        # write code here
        if len(array)==0 or len(array[0])==0:
            return False
        i = 0
        j = len(array[0])-1
        while i < len(array) and j>=0:
            if array[i][j]==target:
                return True
            elif array[i][j] < target:
                i+=1
                continue
            else:
                j-=1
                continue
        return False

m=[[0,1,3,4,5,7,8,11,13,15,18,21,24,27,30,32,35,36,39,41,42,43,46,49,52,55,58,60,63,66,67,69,72,75,78,80,81,82,85,86],
   [1,4,6,8,11,12,15,17,18,20,23,24,27,30,33,34,38,39,42,44,47,48,51,52,55,57,59,62,64,67,70,72,75,77,81,83,84,87,90,91],
   [4,7,8,11,14,16,18,20,21,24,27,29,32,35,36,39,40,42,44,46,49,52,54,56,58,60,61,64,67,70,73,76,78,81,84,87,89,91,93,96],
   [5,8,10,13,15,19,21,23,24,27,29,31,34,37,38,41,43,45,46,49,52,55,58,59,61,64,67,69,71,72,76,78,79,83,87,90,91,94,96,97],
   [6,11,14,16,18,22,24,27,29,32,33,35,36,40,42,44,47,50,51,52,54,58,60,62,64,67,70,73,76,79,82,84,87,88,91,94,97,99,101,102]]
s=Solution()
a= s.Find(2,m)
print(a)